﻿using Engine;
using Game;

namespace Mekiasm
{
    public class CoalGeneratorWidget : BaseEnergyWidget
    {
        public ComponentCoalGenerator Component;
        public MekProgressWidget progressWidget = new MekProgressWidget(MekProgressWidget.ProgessType.flame) { Size = new Vector2(32, 32), VerticalAlignment = WidgetAlignment.Center, Margin = new Vector2(0, 10) };
        public CoalGeneratorWidget(ComponentCoalGenerator componentCoalGenerator, ComponentMiner componentMiner) : base(componentMiner)
        {
            Component = componentCoalGenerator;
            var mStackCenter = new StackPanelWidget() { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center };
            var Charge = new MekInventorySlotWidget() { Size = new Vector2(48, 48) };
            var Fuel = new InventorySlotWidget() { Size = new Vector2(48, 48) };
            Charge.AssignInventorySlot(Component, 0);
            Fuel.AssignInventorySlot(Component, 1);
            Charge.ConfigSlotMode(componentMiner);
            mStackCenter.AddChildren(Charge);
            mStackCenter.AddChildren(progressWidget);
            mStackCenter.AddChildren(Fuel);
            CanvasMain.AddChildren(mStackCenter);
            setTitle("火力发电机");
        }

        public override void Update()
        {
            progressWidget.SetProgress(Component.CraftProgress);
            SetPowerProgress((float)Component.Power / (float)Component.MaxPower);
            SetLeftBottomMoreInfo($"燃料：{Component.Slots[0].FuelAmount}\n产能: {ILibrary.FormatPowerUse(Component.InputPowerLimit)}\n输出:{ILibrary.FormatPowerUse(Component.OutputPowerLimit)}\n当前储能:{ILibrary.FormatPower(Component.Power)}\n最大储能:{ILibrary.FormatPower(Component.MaxPower)}");
        }

    }
}
